package ooday02;
//继承的是父类的成员变量和普通方法，不包括构造方法，父类的构造方法是被子类通过super来调用
public class ExtendsTest {
    public static void main(String[] args) {
        Studnet zg =new Studnet();
        zg.name="张光";
        zg.age=23;
        zg.address="寮房";
        zg.className="jsd";
        zg.stuId="001"; 
        zg.eat();
        zg.sleep();
        zg.sayHI();
        zg.study();

         //重写方法被调用是，看对象的类型来执行方法(new谁就调谁)
        Studnet ll=new Studnet("李林",22,"南昌","jsd","008");
        ll.eat();
        ll.sleep();
        ll.sayHI(); //调用Student类重写之后的
        ll.study();

        Teacher zl =new Teacher("赵亮",36,"山东",6000.0);
        zl.eat();;
        zl.sleep();
        zl.sayHI();
        zl.teach();

        Doctoe wpf =new Doctoe("王鹏飞",45,"山西","主治医师");
        wpf.eat();
        wpf.sleep();


        wpf.sayHI();
        wpf.cut();

        //演示超类不能访问派生类
        Person p =new Person();
        p.name="人";
        p.age=1;
        p.address="未知";
        p.eat();
        p.sleep();
        p.sayHI();
        //p.stuId="005"; /编译错误，超类不能访问派生类
    }
}
